********************************************************************************

* Offer probability, by subject group, Table D1

********************************************************************************

clear
use "${data}merged_tripos.dta"
do "${blocks}variables_sample_as"

	
	keep if Course != "PBS"
	keep if Course != "Other"
	count
	
	keep if ApplyYear<=2016
	
	replace Offers = 0 if Offers != 1
	
gen male=1 if Gender=="Male"
replace male=0 if Gender=="Female"

drop if ApplyYear>=2017
drop if GCSEAStarCount == .
drop if as_number<3

egen mean_astar = mean(GCSEAStarCount)
egen sd_astar   = sd(GCSEAStarCount)
gen std_astar   = (GCSEAStarCount - mean_astar) / sd_astar
\
label var std_maths_percent "Math score"
label var maths_modules "Math modules"
label var std_astar "Number of A* in General exams"
label var male "Male"

reg Offers male if (Course=="Economics" | Course=="Engineering" | Course=="Maths")
reg Offers male if (Course=="Medicine" | Course=="Law")

reg Offers male std_astar std_maths_percent maths_modules if (Course=="Economics" | Course=="Engineering" | Course=="Maths")
eststo r1

reg Offers male std_astar if (Course=="Medicine" | Course=="Law")
* we drop maths qualifications because a lot of students don't take it for these subjects  
eststo r2

esttab r1 r2 using "${tables}offer_regressions.tex", cells(b(pval(pval) fmt(2)) se(par fmt(2))) keep(male std_astar std_maths_percent maths_modules)  collabels(none) star(* 0.10 ** 0.05 *** 0.01) ///
eqlabels(none) label varwidth(25) nonumbers posthead("& MI subjects &  Non-MI subjects \\" "& (1) & (2)  \\ \midrule") nonumbers mlabels(none) se(%9.2f) /// 
gaps booktabs nonotes replace
